#include "autolamps.h"
static char  re_states;
static char re_states2;
void autolamps_run()
{
re_states=GET_INPUT;
 if(AUTO!=re_states)
        {
                re_states2=LIGHTSOFF;
        }
        switch(re_states)
        {
        case OFF:
        OUT_PORT=TURN_OFF;
        break;
        case AUTO:
                GET_ADC_INFO;
                switch(re_states2)
                {
                case LIGHTSOFF:
                if(ADRESH>PERC60)
                {OUT_PORT=TURN_PARKLAMPS;re_states2=HALFLIGHT;}
                
                break;
                
                case HALFLIGHT:
                if(ADRESH<PERC40)
                {OUT_PORT=TURN_OFF;re_states2=LIGHTSOFF;}
                if(ADC_RESULT>PERC80)
                {OUT_PORT=TURN_ALLLAMPS;re_states2=LIGHTSON;}
                break;

                case LIGHTSON:
                if(ADRESH<PERC80)
                {OUT_PORT=TURN_PARKLAMPS;re_states2=HALFLIGHT;}
                break;
                }

        break;
        case HEADLAMPS:
        OUT_PORT=TURN_HEADLAMPS;
        break;
        case PARKLAMPS:
        OUT_PORT=TURN_PARKLAMPS;
        break;
        }
}

void autolamps_init()

{
	re_states=RESET;
	
}